<cfparam name="Product_Category_ID" type="integer" default="0" />
<cfparam name="returnUI" type="string" default="productCategories" />
<!--- passback takes key/value pairs separated by semi-colons.  any pairs will be added to form submission or appended to query strings --->
<!--- <cfparam name="passback" type="string" default="" /> --->

<cfscript>
	productCategory = request.productCategoryGateway.get(Product_Category_ID = Product_Category_ID);
</cfscript>

<cfif IsNumeric(productCategory.getProduct_Category_ID())>

	<script type="text/javascript" language="javascript">
	<!--
		var confirmDelete = function() {
			if (confirm("Are you sure you want to delete this product category?")) {
				alert("confirmed");	
			}
		}
		$(function(){
			$("#productCategoryForm").validate({
				// 
				debug: true,
				rules: {
					Category: {required: true},
				},
				messages: {
					Category: "Required"
				},
				focusCleanup: true,
				errorPlacement: function(error, element) {
					$(element).prev("label").children("span").remove();
					error.appendTo(element.prev("label"));
				},
				errorElement: "span",
				errorClass: "label label-danger",
				validClass: "label label-info",
				highlight: function(element, errorClass, validClass) {
					$(element).prev("label").children("span").removeClass(validClass).addClass(errorClass);
				},
				unhighlight: function(element, errorClass, validClass) {
					$(element).prev("label").children("span").removeClass(errorClass).addClass(validClass);
				}
			});
		})
	//-->
	</script>
	
	<cfform id="productCategoryForm" name="productCategoryForm" action="#script_name#" role="form" method="post">
		<input type="hidden" name="action" value="saveProductCategory" />
		<input type="hidden" name="ui" value="productCategories" />
		<cfinput type="hidden" id="Product_Category_ID" name="Product_Category_ID" value="#productCategory.getProduct_Category_ID()#" />

		<cfoutput>
			<div class="row">
				<div class="col-lg-4">
					<div class="form-group">
						<label for="Category">Category<span class="label label-info">Required</span></label>
						<input id="Category" name="Category" type="text" class="form-control" value="#productCategory.getCategory()#">
					</div>
					<div class="form-group">
						<label for="Subcategory">Subcategory</label>
						<input id="Subcategory" name="Subcategory" type="text" class="form-control" value="#productCategory.getSubcategory()#">
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-lg-12">
					<div class="well well-sm" style="width: 100%;">
						<a href="?ui=#returnUI#" class="btn btn-info">Cancel</a>
						<button type="submit" id="saveButton" name="saveButton" class="btn btn-info input">Save</button>
						<cfif productCategory.getProduct_Category_ID() gt 0> <a href="##" class="btn btn-info" onclick="confirmDelete(); return false;">Delete</a></cfif>
					</div>
				</div>
			</div>
		</cfoutput>
	</cfform>

<cfelse>
	<div class="alert alert-info">Product catgory not found</div>
</cfif>

